var util = require('../../utils/util.js');
var ajax = require('../../utils/ajax.js');
var common = require('../../utils/common.js');
var PageBase = require('../../common/PageBase.js');
var app = getApp();

Page(common.extendPage(PageBase, {
    data: {
        winHei: 0,
        dataLoaded: false,
        orderInfo: {},
    },

    onLoad: function(options) {
        this._options = options;

        common.initApp({
            extSuc: () => {},
            loginSuc: () => {
                this._fetch();
                this.$loginSuc();
            },
            sysInfoSuc: (sysInfo) => {
                this.setData({
                    winHei: app.getWinHei(),
                });
            },
        });
    },

    /**
     * 获取订单详情
     */
    _fetch: function() {
        var _self = this;
        var url = "/market/Activity/orderInfo";
        var data = {
            orderId: this._options.orderId
        };

        ajax.G({
            url,
            data,
            success: function(data) {
                var {
                    info
                } = data.result;

                _self.setData({
                    orderInfo: info,
                    dataLoaded: true,
                })
            }
        })
    }
}));